package com.xiaoshuidi.cloud.module.contract.enums.bill;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 账单优惠类型
 */
@Getter
@AllArgsConstructor
public enum OrderDiscountEnum {
    FIRST("first","周期性费用"),
    LAST("last","一次性费用"),

    AMOUNT("amount","金额优惠"),
    RATE("rate","一次性费用"),
    ;

    private final String code;
    private final String name;

    private static Map<String, OrderDiscountEnum> enumMap = new HashMap<>();
    static {
        OrderDiscountEnum[] values = OrderDiscountEnum.values();
        for (OrderDiscountEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }
    public static OrderDiscountEnum getEnum(String num){
        return enumMap.get(num);
    }

    public static String getBillDiscountOrderByCode(String code) {
        OrderDiscountEnum[] orderDiscountEnums = values();
        for (OrderDiscountEnum orderDiscountEnum : orderDiscountEnums) {
            if (orderDiscountEnum.code==code) {
                return orderDiscountEnum.code;
            }
        }
        return null;
    }
}
